import axios from 'axios'
import config from '@/config'

export function getRoomEvents3(physical_room_ids, start, end) {
  return axios({
    method: 'post',
    url: config.serverURI + config.api.get_events3,
    data: {
      physical_room_ids,
      start,
      end
    }
  })
}

export function getRoomEvents(id, type='all', physical_room_id) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.get_events,
        data: {
            type,
            physical_room_id
        }
    })
}

export function updateIcal(id, data) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.update_ical + id + '/',
        data: data
    })
}

export function updateLogicalIcal(id) {
    return axios({
        method: 'get',
        url: config.serverURI + config.api.update_logical_ical + id + '/',
    })
}

export function deleteIcal(ical_list) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.delete_ical,
        data: {ical_list}
    })
}

export function insertOrder(data) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.insert_order,
        data
    })
}

export function getIcsUrls(id) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.get_ics_urls,
        data: {
            logical_room_id: id
        }
    })
}

export function updateLogicalIcs(id) {
    return axios({
        method: 'get',
        url: config.serverURI + config.api.update_logical_ical + id + '/',
    })
}

export function addIcs(physicalRoom, data) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.add_ics_url,
        data: {id: physicalRoom, data}
    })
}

export function removeIcs(id) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.remove_ics_url,
        data: {id}
    })
}

export function updateIcs(id, data) {
    return axios({
        method: 'post',
        url: config.serverURI + config.api.update_ics_url,
        data: {id, data}
    })
}
